package pub.xspace.nova.common.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import pub.xspace.nova.common.constant.Constant;
import pub.xspace.nova.common.domain.AjaxResult;

@ControllerAdvice("pub.xspace.nova")
public class GlobalExceptionHandler {

	@ExceptionHandler(Exception.class)
	@ResponseBody
	public AjaxResult error(Exception e) {
		return new AjaxResult(Constant.RESULT_FAIL_CODE, Constant.RESULT_FAIL_MSG);
	}
	
	@ExceptionHandler(CommonException.class)
	@ResponseBody
	public AjaxResult error(CommonException e) {
		return new AjaxResult(e.getCode(),e.getMsg());
	}
}
